package mate.task.odin;

/**
 * This class represents a single user account.
 * @author Leonard
 * @version 1.0
 */
public class UserAccount {

	private String name;
	private String email;
	private String username;
	private String password;
	private ToDoList list;
	private int xp;
	private int zone;
	private String zoneName;
	/**
	 * Creates a new UserAccount object with given information.
	 * @param name The user's full name
	 * @param email The new user's email
	 * @param username The new user's username
	 * @param password The new user's password
	 */
	public UserAccount(String name, String email, String username, String password){
		this.name = name;
		this.email = email;
		this.username = username;
		this.password = password;
		list = new ToDoList();
		xp = 0;
		zone = 0;
	}
	
	/**
	 * Returns the name of the user
	 * @return The name of the user
	 */
	public String getName(){
		return name;
	}
	
	/**
	 * Returns the email of the user
	 * @return The email of the user
	 */
	public String getEmail(){
		return email;
	}
	
	/**
	 * Returns the username of the user
	 * @return The username of the user
	 */
	public String getUsername(){
		return username;
	}
	
	/**
	 * Returns the password of the user
	 * @return The password of the user
	 */
	public String getPassword(){
		return password;
	}
	
	public int getXP(){
		return xp;
	}
	public int getZone(){
		return zone;
	}
	public void setZone(int z){
		if(z > 1){
			return;
		}
		this.zone = z;
		xp = 0;
	}
	public void addXP(){
		this.xp = xp+10;
		if(xp >= 100){
			setZone(zone + 1);
		}
	}
	/**
	 * Returns whether this UserAccount object is equal to another UserAccount object
	 * @param other The object to compare
	 * @return Whether the objects are equal based on equal usernames
	 */
	public boolean equals(Object other){
		if(other instanceof UserAccount){
			UserAccount otherUser = (UserAccount)other;
			return (username.equals(otherUser.getUsername()));
		}
		else
			return false;
	}
	
	/**
	 * Returns the list of the user's to do items
	 * @return The list of the user's to do items
	 */
	public ToDoList getList(){
		return list;
	}

	public String getZoneName() {
		String p = "";
		if(zone == 0){
			p = "FOREST";
		}
		if(zone == 1){
			p = "VOLCANO";
		}
		return p;
	}

	
}
